#【进服获得全服唯一ID】
execute as @a[tag=!NewPlayer,tag=!OldPlayer,limit=1,sort=nearest] run scoreboard players operation @s DataID = PlayerCount System
execute as @a[tag=!NewPlayer,tag=!OldPlayer,limit=1,sort=nearest] run scoreboard players add PlayerCount System 1
#【触发器系统】
scoreboard players enable @a[tag=!OldPlayer] SystemGift
scoreboard players enable @a[tag=!Group] SystemGift
scoreboard players enable @a[tag=admin] SystemAdmin

#【新人系统】初始化 -> 跳转function nw:system/system0
scoreboard players set @a[tag=!NewPlayer,tag=!OldPlayer,limit=1,sort=nearest] SystemDeath 2
#【新人系统】初始化新玩家data数据
scoreboard players set @a[tag=!NewPlayer,tag=!OldPlayer,limit=1,sort=nearest] DataGold 0
scoreboard players set @a[tag=!NewPlayer,tag=!OldPlayer,limit=1,sort=nearest] DataVIP 0
scoreboard players set @a[tag=!NewPlayer,tag=!OldPlayer,limit=1,sort=nearest] DataComRank 0
scoreboard players set @a[tag=!NewPlayer,tag=!OldPlayer,limit=1,sort=nearest] DataEXCard 10
scoreboard players set @a[tag=!NewPlayer,tag=!OldPlayer,limit=1,sort=nearest] DataHeroCard 15
execute as @a[tag=!NewPlayer,tag=!OldPlayer,limit=1,sort=nearest] run tellraw @a [{"text":"                                          \n","color":"gold","bold":true,"italic":false,"underlined":false,"strikethrough":true,"obfuscated":false},{"text":" 欢  迎  新  人： ","color":"green","bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"selector":"@s","color":"yellow","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"  ID:","color":"white","bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"score":{"objective":"DataID","name":"@s"},"color":"aqua","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"\n\n新人奖励： ","color":"white","bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"英雄体验卡","color":"light_purple","bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"×10","color":"white","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"  英雄卡","color":"dark_purple","bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"×15","color":"white","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"\n\n新人礼包","color":"green","bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":" 输入/trigger SystemGift set 1领取","color":"white","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"\n包含[ ","color":"white","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"金币","color":"gold","bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"×500","color":"white","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":" 全英雄使用权","color":"gold","bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"20分钟 ]","color":"white","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"\n                                          ","color":"gold","bold":true,"italic":false,"underlined":false,"strikethrough":true,"obfuscated":false}]
tag @a[tag=!NewPlayer,tag=!OldPlayer,limit=1,sort=nearest] add NewPlayer


#【黑夜狂欢】持续更新：boss栏显示目标
bossbar set minecraft:night_time players @a
execute if score DayTime System matches 13000..23000 run bossbar set minecraft:night_time visible true
execute unless score DayTime System matches 13000..23000 run bossbar set minecraft:night_time visible false

#【分钟计时】每秒+1
scoreboard players add TimeSecond System 1
#【分钟计时】60s时执行minute函数
execute if score TimeSecond System matches 60.. run function nw:system/minute

#【逢魔时刻】剩余选择boss时间每秒-1
execute if score ChangeBossTiming System matches 1.. run function nw:system/system_module/boss_second

#【大逃杀对局】TimeClock时间每秒-1
execute if score TimeClock DieOutInfo matches -1 run effect give @a[team=DieOutTeam] instant_damage 1 0 true
execute if score TimeClock DieOutInfo matches 1.. run function nw:system/system_module/dieout_0second

#【在线玩家】每秒重新记录在线时间
execute store result score OnlinePlayerCount System if entity @a
execute store result score AlivePlayer System if entity @a[tag=Alive]

#【击杀与连杀判定】
execute as @a[scores={SystemKill=1..}] at @s run function nw:system/system_util/comkill

#【雨】每秒-1
execute if score SystemRain System matches 1.. run weather rain
execute if score SystemRain System matches 1.. run scoreboard players remove SystemRain System 1
execute if score SystemRain System matches 0 run weather clear

#【丢弃物品】每秒-1
scoreboard players remove @a[scores={SystemOutItem=1..}] SystemOutItem 1

#【随机数】每秒重新生成随机数
function nw:system/system_util/random

#【闲置战斗匹配】周围无战斗中玩家 每秒-1，并提示玩家周围已没有战斗中的玩家
execute unless score AlivePlayer System matches 0..1 as @a[scores={SystemNotAround=10}] at @s unless entity @a[tag=Alive,distance=0.1..30] run tellraw @s [{"text":"您的周围已没有战斗中玩家，即将在 ","color":"white","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"score":{"objective":"SystemNotAround","name":"@s"},"color":"aqua","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"s ","color":"gold","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"后自动匹配其他玩家","color":"white","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}]
execute unless score AlivePlayer System matches 0..1 as @a[scores={SystemNotAround=1..5}] at @s unless entity @a[tag=Alive,distance=0.1..30] run tellraw @s [{"text":"您的周围已没有玩家，即将在 ","color":"white","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"score":{"objective":"SystemNotAround","name":"@s"},"color":"aqua","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"s ","color":"gold","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"后自动匹配其他玩家","color":"white","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}]
execute unless score AlivePlayer System matches 0..1 as @a[scores={SystemNotAround=1..}] at @s unless entity @a[tag=Alive,distance=0.1..30] run scoreboard players remove @s SystemNotAround 1

